package com.hhwy.framework.common;

import java.util.Locale;
import java.util.regex.Pattern;

import com.hhwy.framework.util.IoTools;


/**
 * <b>类 名 称：</b>Constants <br/>
 * <b>类 描 述：</b>系统公有常量<br/>
 * <b>创 建 人：</b>lihuiming<br/>
 * <b>修 改 人：</b>Administrator<br/>
 * <b>修改时间：</b>2014年8月4日 上午9:45:06<br/>
 * <b>修改备注：</b><br/>
 * @version 1.0.0<br/>
 */
public class Constants {
	/**
	 * 系统运行模式--开发
	 */
	public final static String RUNTIME_MODE_DEVELOPMENT = "development";
	/**
	 * 系统运行模式--runtime运行
	 */
	public final static String RUNTIME_MODE_RUNTIME = "runtime";
	
	public final static String RESTAPI_URI= "/restapi";
	
	public final static String PK = "id";
	public final static String ENTITY_CACHE_PRE = "entity::";
	
	public final static String ENTITY_PACKAGE = "com.hhwy";
	
	public final static String NEW_OBJECT_PRE = "new::";
	
	public final static String OneToMany = "OneToMany";
	public final static String OneToOne = "OneToOne";
	public final static String ManyToMany = "ManyToMany";
	public final static String ManyToOne = "ManyToOne";
	
	public final static String BLANK_STR = "";
	
	
	public final static String DICT_SUFFIX = "Entity";
	/**原型*/
	public final static String SCOPE_PROTOTYPE="prototype";
	/**单例*/
	public final static String SCOPE_SINGLETON="singleton";
	/**文件存储目标配置项名称*/
	public final static String FILE_STORE_TARGET = "unstructured.store.target";
	/**文件存储目录*/
	public final static String FILE_STORE_DIRECTORY = "unstructured.store.directory";
	
	/**动态数据源配置表*/
	public final static String DATASOURCE_CONFIG_TABLE = "t_datasource_config";
	
	public static final String WEB_LIB = "/WEB-INF/lib/";
	public static final String WEB_LIB_PATH = IoTools.getABSPATH() + "WEB-INF/lib/";
	public static final String PLUGIN_DIR = "plugins";
	public static final String INIT_PLUGIN_MAPPING_NAME = "plugin-core";
	public static final String PLUGIN_DIR_PATH = IoTools.getABSPATH()+PLUGIN_DIR;
	
	/**
	 * 插件压缩文件上传路径
	 */
	public static final String UPLOAD_FOLDER_PATH = IoTools.getABSPATH()+PLUGIN_DIR;
	
	/**
	 * 插件压缩文件解压路径
	 */
	public static final String UNCOMPRESSION_PATH = IoTools.getABSPATH()+PLUGIN_DIR;
	
	/**
	 * 插件信息记录文件
	 */
	public static final String PLUGINS_RECORD_FILE =  "/plugins_info.properties";
	
	/**
	 * 插件信息记录文件路径
	 */
	public static final String PLUGINS_RECORD_FILE_PATH = UPLOAD_FOLDER_PATH + PLUGINS_RECORD_FILE;
	
	/**
	 * 插件前台配置文件
	 */
	public static final String PLUGIN_UI_CONFIG_FILE = "/WEB-INF/plugin-config.json";
	/**
	 * 插件信息文件
	 */
	public static final String PLUGIN_INFO_FILE = "/META-INF/MANIFEST.MF";
	/**
	 * 插件type:jar表示后台插件，page表示前台插件
	 */
	public static final String PLUGIN_TYPE_JAR = "jar";
	public static final String PLUGIN_TYPE_PAGE = "page";
	
	public static final String JAR_PROTOCOL = "jar:file:";
	/**系统初始化基本信息文件*/
	public static final String SYSTME_PROPERTIES = "system-config.properties"; 
	/**
	 * 系统初始化数据源信息文件
	 */
	public static final String DB_PROPERTIES = "db.properties";
	/**
	 * url后缀名正则表达式
	 */
	public static final Pattern URL_SUFFIX = Pattern.compile("(\\.\\w+)(\\??)");
	/**
	 * 获取servletPath中的相对路径，去掉/view以及.xxx后缀
	 */
	public static final Pattern SERVLET_PATH = Pattern.compile("(/view)?(?<relativePath>(/\\w+)+[^\\.(/$)])");
	
	/**
	 * 插件加载时的三个属性（插件名，lib包路径，排序号）
	 */
	/**
	 * 插件名
	 */
	public static final String PLUGIN_NAME_KEY = "pluginName";
	/**
	 * lib包路径
	 */
	public static final String PLUGIN_LIB_PATH_KEY = "pluginLibPath";
	/**
	 * 排序号
	 */
	public static final String SORT_NUM_KEY = "sortNum";
	/**
	 * session中系统默认语言的key
	 */
	public static final String FWEB_LANGUAGE = "fweb_language";
	/**
	 * 系统默认语言
	 */
	public static final String DEFAULT_LANGUAGE = Locale.getDefault().toLanguageTag();
	/**
	 * 从context中获取Tomcat合并后的web.xml文件的key
	 */
	public static final String TOMCAT_MERGEDWEBXML_KEY = "org.apache.tomcat.util.scan.MergedWebXml";
	/**
	 * Tomcat合并后的web.xml文件
	 */
	public static String TOMCAT_MERGEDWEBXML = null;
	/**
	 * 是否过滤按照组织权限过滤数据
	 */
	public static final String IS_FILTER_DATA_KEY = "fwebIsFilterData";
	/**
	 * 使用指定的的filter进行数据权限的过滤
	 */
	public static final String DATA_FILTER_NAME_KEY = "fwebDataFilterName";
	/**
	 * 需要过滤的用户id参数的key
	 */
	public static final String FILTER_USER_ID_KEY = "fwebFilterUserId";
	/**
	 * 默认的DataFilter bean名称
	 */
	public static final String DEFAULT_DATA_FILTER_NAME = "defaultDruidFilter";
	/**
	 * 数据权限过滤所依赖的字段
	 */
	public static final String ORG_NO_FIELD_NAME = "org_no";
	
}
